<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no" />
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="../c/aui.css" />
	<style>
	#video{
		background:url('../i/loading_200.png');
		background-position: center;
		background-repeat: no-repeat;
	}
	</style>
</head>
<body>
	<div id="video"></div>
</body>
<script type="text/javascript" src="../j/api.js"></script>
<script type="text/javascript">
	var v = [];
	apiready = function() {
		$('#video').css('height',(api.safeArea.top+(api.winWidth/1.8))+'px')
		if(!api.pageParam['aid']){
			return _alert('资源不存在或已下架',function(ret,err){
				_close();
			})
		}
		oxPlayer = api.require('oxPlayer');
		oxPlayer.addEventListener(function(ret, err) {
			// console.log(JSON.stringify(ret));
			switch (ret.code) {
				case 0:
					// 返回
					//  oxPlayer.remove();
					_close();
					break;
				case 1:
				default:
			}
		});
		data();
		// 回到屏幕
		api.addEventListener({
			name: 'viewappear'
		}, function(ret, err) {
		});
		// 离开屏幕
		api.addEventListener({
			name: 'viewdisappear'
		}, function(ret, err) {
			oxPlayer.pause();
		});
		//应用进入后台事件
		api.addEventListener({
			name: 'pause'
		}, function(ret, err) {
		});
		// 应用从后台回到前台事件
		api.addEventListener({
			name: 'resume'
		}, function(ret, err) {
			oxPlayer.pause();
		});
		api.addEventListener({
			name : 'keyback'
		}, function(ret, err) {
			oxPlayer.isFull(function(ret) {
				if(ret.isFull){
					oxPlayer.exitFullScreen();
				}else{
					_close();
				}
			});
		});
	};
	function data(){
		var url = 'fang_view';
		api.openFrame({
			name: url,
			bounces:true,
			url: _h_w + url + '.html',
			rect: {
				x: 0,
				y: api.safeArea.top+(api.winWidth/1.8),
				w: 'auto',
				h: 'auto',
			},
			pageParam:api.pageParam,
			bgColor: 'rgba(0,0,0,0)',
		})
	}
	function fixdPlay(){
		 oxPlayer.remove();
	//	console.log(JSON.stringify(v.data))
		oxPlayer.fixdPlay({
				rect: {
						x: 0,
						y: api.safeArea.top,
						h: api.winWidth/1.8,
				},
				addPositionEvent: false,
				showBack: true, //返回按钮是否显示小屏幕
				showSelect: true, //选集按钮是否显示
				showSpeed: true, //倍速按钮是否显示
				showDlna: {
					small: false,
					full: false
				}, //投屏按钮是否显示 small 小屏是否显示 full 全屏是否显示
				showShot: {
					small: false,
					full: false
				}, //截图按钮是否显示 small 小屏是否显示 full 全屏是否显示
				// showShot: false, //截图按钮是否显示
				openCache: true, //是否开启缓存
				showBottomProcess: true,
				autoPlay: true, //默认false
				index: 0,
				fixed:true,
				radius:0,
				backgroundAlpha:0,//0 背景透明度
				hideControl:false,
				showMore:{small:false,full:false},//跟多按钮是否显示
				showDunmaku:{small:false,full:false},//弹幕按钮是否显示
				forceDeviceOrientation:api.systemType=='ios'?false:true,
				// backgroundHolder:_i+'loading_200.png',
				loop:false,
				data: v.data
		},function(ret,err){
			console.log(JSON.stringify(ret)+JSON.stringify(err))
		});
		//  console.log(JSON.stringify(v.data))
	}
	function playIndex(index){
		oxPlayer.playIndex({index:index});
	}
	function shuaxin(ret){
		v = ret;
		setTimeout(function(){
			fixdPlay();
		},300)
	}
</script>

</html>
